package com.siwei.mes.entity.laboratory;


import com.siwei.mes.common.util.DateHelper;
import com.siwei.mes.common.util.NullUtils;
import com.siwei.mes.entity.sync.erp.ErpProject;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.experimental.Accessors;

import javax.persistence.Transient;

@Data
@Accessors(chain = true)
@ApiModel(value = "ContractData", description = "上海协会合同信息实体")
public class ContractData {
    @Transient
    @ApiModelProperty(value = "Contract_Id")
    private String contractId;

    @Transient
    @ApiModelProperty(value = "客户编号")
    private String custNo;

    @Transient
    @ApiModelProperty(value = "客户编号id")
    private String custId;

    @Transient
    @ApiModelProperty(value = "合同编号")
    private String contractNo;

    @Transient
    @ApiModelProperty(value = "工程名称")
    private String contractProjectName;

    @Transient
    @ApiModelProperty(value = "工程地址")
    private String contractProjectAddress;

    @Transient
    @ApiModelProperty(value = "签订日期")
    private String contractSignDate;

    @Transient
    @ApiModelProperty(value = "报建编号")
    private String contractBjbh;

    @Transient
    @ApiModelProperty(value = "建设单位")
    private String contractJsdw;

    @Transient
    @ApiModelProperty(value = "施工单位")
    private String contractSgdw;

    @Transient
    @ApiModelProperty(value = "监理单位")
    private String contractJldw;

    @Transient
    @ApiModelProperty(value = "合同类型 0表示报建合同 1表示非报建合同")
    private String contractType;


    @Transient
    @ApiModelProperty(value = "")
    private String contractProjectNameAddOn;

    @Transient
    @ApiModelProperty(value = "上传标识")
    private String uploadFlag;

    /**
     * 组装工程信息
     *
     * @param erpProject
     * @param contractId
     * @param erpCustomerLaboratoryId
     * @return
     */
    public static ContractData payloadInfo(ErpProject erpProject, String contractId, String erpCustomerLaboratoryId) {
        ContractData contractData = new ContractData();
        contractData.setContractNo(NullUtils.ifNull(erpProject.getContractNo()));
        contractData.setContractProjectName(NullUtils.ifNull(erpProject.getLaboratoryProjectName()));
        contractData.setContractProjectAddress(NullUtils.ifNull(erpProject.getProjectAddress()));
        contractData.setContractSignDate(erpProject.getSignDate() == null ? "" : DateHelper.formatDateTime(erpProject.getSignDate()));
        contractData.setContractBjbh(NullUtils.ifNull(erpProject.getBjbh()));
        contractData.setContractJsdw(NullUtils.ifNull(erpProject.getJsdw()));
        contractData.setContractSgdw(NullUtils.ifNull(erpProject.getSgdw()));
        contractData.setContractJldw(NullUtils.ifNull(erpProject.getJldw()));
        contractData.setContractType(NullUtils.ifNull(erpProject.getContractType(), "1"));
        contractData.setContractId(contractId);
        contractData.setCustId(NullUtils.ifNull(erpCustomerLaboratoryId));
        return contractData;
    }
}
